package com.baidu.process.chat.core.web.bean.eval;

import com.alibaba.fastjson.JSONObject;
import com.sun.org.apache.regexp.internal.RE;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * APP渠道满意度调查模板
 * @author: lws
 * @date: 2022/11/8
 */
@Data
public class AppEvalTemplate {

    private String businessID;
    private int finish_state;
    private String session_id;
    private String title;
    private String desc;
    private Long expireDate;
    private List<Map<String, Object>> quesions;
    private String star_title;
    private int star_count;
    private String[] star_items;
    private String[] selected_items;
    private String reason;

    /**
     * 初始化APP满意度评价模板
     * @param session_id
     * @return
     */
    public static AppEvalTemplate instanceOf (String session_id) {
        AppEvalTemplate result = new AppEvalTemplate();
        result.setBusinessID("satisfaction_survey_msg_1030");
        result.setFinish_state(0);
        result.setSession_id(session_id);
        result.setTitle("满意度评价");
        result.setDesc("为了更好的为您提供服务，请您对我们的服务进行评价。");
        result.setQuesions(getQuesionsList());
        // 过期时间为72小时
//        result.setExpire_date(System.currentTimeMillis() + 3*24*60*60*1000);
        result.setStar_title("满意度");
        result.setStar_count(0);
        result.setStar_items(new String[]{"服务态度", "回复速度", "问题解答", "其他"});
        result.setSelected_items(new String[]{});
        result.setReason("");
        return result;
    }

    /**
     * 组装quesions
     * @return
     */
    private static List<Map<String, Object>> getQuesionsList(){
        List<Map<String, Object>> quesions = new ArrayList<>();
        Map<String, Object> quesion = new HashMap<>();
        quesion.put("question_content", "您的问题是否已解决？");
        quesion.put("question_id", "solve");
        List<Map<String, Object>> answers = new ArrayList<>();
        Map<String, Object> answer1 = new HashMap<>();
        answer1.put("answer_content", "已解决");
        answer1.put("answer_id", 1);
        answer1.put("select", 0);
        Map<String, Object> answer2 = new HashMap<>();
        answer2.put("answer_content", "未解决");
        answer2.put("answer_id", 2);
        answer2.put("select", 0);
        answers.add(answer1);
        answers.add(answer2);
        quesion.put("answers", answers);
        quesions.add(quesion);
        return quesions;
    }
}
